@extends('app')

@section('import')
    <link rel="stylesheet" href="asset/style/login.css" media="all">
@endsection

@section('content')
    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header" style="padding-bottom: 0">
                <h2>{{ $app_name }}</h2>
            </div>
            <form method="post" class="layui-form" >
                @csrf
                <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-xs7">
                            <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                            <input type="text" name="captcha" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input input-val">
                        </div>
                        <div class="layui-col-xs5">
                            <div style="margin-left: 10px;">
                                <img src="{{captcha_src()}}" style="width:100%;border:1px solid #d2d2d2;cursor: pointer;border-width: 1px;" onclick="this.src='{{captcha_src()}}'+Math.random()">
                                @if($errors->has('captcha'))
                                    <div class="col-md-12">
                                        <p class="text-danger text-left"><strong>{{$errors->first('captcha')}}</strong></p>
                                    </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item" style="margin-bottom: 20px;">
                    <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                    <a  class="layadmin-user-jump-change layadmin-link" id="job" style="margin-top: 7px;cursor: pointer">我要加入？</a>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login">登 入</button>
                </div>
            </div>
            </form>
        </div>

        <div class="layui-trans layadmin-user-login-footer">

            <p>© 2020 <a href="{{ $front_url }}" target="_blank">{{ substr($front_url,7) }}</a></p>
        </div>


    </div>
    <script>
        layui.config({
            base: 'asset/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'user','layer'], function(){
            var $ = layui.$
                ,setter = layui.setter
                ,admin = layui.admin
                ,form = layui.form
                ,router = layui.router()
                ,search = router.search;

            form.render();

            //提交

            form.on('submit(login)', function(data){

                var data=data.field;
                $.ajax({
                    type: 'POST',
                    url: "/login",
                    data:data,
                    success: function (data) {
                        layer.alert(data.msg,function(index){
                            parent.layer.closeAll();
                            if (data.code==0){
                                self.location.href='/';
                            }
                        });
                    },
                    error: function (data) {},
                })
                return false;
            });


            $('#job').on('click', function(){
                //示范一个公告层
                layer.open({
                    type: 1
                    ,title: false //不显示标题栏
                    ,closeBtn: false
                    ,area: '300px;'
                    ,shade: 0.8
                    ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    ,btn: ['立即加入', '残忍拒绝']
                    ,btnAlign: 'c'
                    ,moveType: 1 //拖拽模式，0或者1
                    ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '你想加入后台运营?<br><br>' +
                        '<img src="asset/images/qq_qrcode.jpg" width="100%"><br><br>' +
                        '扫码加入QQ群,一起管理后台!<br><br>' +
                        '我们此后的征途是星辰大海 ^_^' +
                        '</div>'
                    ,success: function(layero){
                        var btn = layero.find('.layui-layer-btn');
                        btn.find('.layui-layer-btn0').attr({

                        });
                    }
                });
            });
        });
    </script>
@endsection
